/**
 * @author     Gabor Greif <ggreif@gmail.com>
 * @copyright  2009-2010 Gabor Greif
 * @license    http://www.opensource.org/licenses/mit-license.php  MIT License
 * @version    Release: 0.0
 */

#ifndef micker_CUNSET_hpp
#define micker_CUNSET_hpp

#include "CommandMap.hpp"

namespace micker {

struct Unset : Comm<CommandMap&>
{
    Unset(CommandMap& cm)
    : Comm<CommandMap&>(ArgumentsMismatch<1>::proc<Env, proc>, cm)
    {}

    static std::string proc(Pref env, const std::string& arg)
    {
        CommandMap::iterator it(env.find(arg));

        if (it != env.end())
        {
            delete it->second.second;
            env.erase(it);
            return "1";
        }

        return "0";
    }
};

} // namespace micker

#endif // micker_CUNSET_hpp
